package com.ruoyi.web.controller.system;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.SysShoestaglogs;
import com.ruoyi.system.service.ISysShoestaglogsService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 鞋标签记录Controller
 * 
 * @author colin
 * @date 2021-08-04
 */
@Controller
@RequestMapping("/system/shoestaglogs")
public class SysShoestaglogsController extends BaseController
{
    private String prefix = "system/shoestaglogs";

    @Autowired
    private ISysShoestaglogsService sysShoestaglogsService;

    @RequiresPermissions("system:shoestaglogs:view")
    @GetMapping()
    public String shoestaglogs()
    {
        return prefix + "/shoestaglogs";
    }

    /**
     * 查询鞋标签记录列表
     */
    @RequiresPermissions("system:shoestaglogs:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(SysShoestaglogs sysShoestaglogs)
    {
        startPage();
        List<SysShoestaglogs> list = sysShoestaglogsService.selectSysShoestaglogsList(sysShoestaglogs);
        return getDataTable(list);
    }

    /**
     * 导出鞋标签记录列表
     */
    @RequiresPermissions("system:shoestaglogs:export")
    @Log(title = "鞋标签记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(SysShoestaglogs sysShoestaglogs)
    {
        List<SysShoestaglogs> list = sysShoestaglogsService.selectSysShoestaglogsList(sysShoestaglogs);
        ExcelUtil<SysShoestaglogs> util = new ExcelUtil<SysShoestaglogs>(SysShoestaglogs.class);
        return util.exportExcel(list, "鞋标签记录数据");
    }

    /**
     * 新增鞋标签记录
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存鞋标签记录
     */
    @RequiresPermissions("system:shoestaglogs:add")
    @Log(title = "鞋标签记录", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(SysShoestaglogs sysShoestaglogs)
    {
        return toAjax(sysShoestaglogsService.insertSysShoestaglogs(sysShoestaglogs));
    }

    /**
     * 修改鞋标签记录
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        SysShoestaglogs sysShoestaglogs = sysShoestaglogsService.selectSysShoestaglogsById(id);
        mmap.put("sysShoestaglogs", sysShoestaglogs);
        return prefix + "/edit";
    }

    /**
     * 修改保存鞋标签记录
     */
    @RequiresPermissions("system:shoestaglogs:edit")
    @Log(title = "鞋标签记录", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(SysShoestaglogs sysShoestaglogs)
    {
        return toAjax(sysShoestaglogsService.updateSysShoestaglogs(sysShoestaglogs));
    }

    /**
     * 删除鞋标签记录
     */
    @RequiresPermissions("system:shoestaglogs:remove")
    @Log(title = "鞋标签记录", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(sysShoestaglogsService.deleteSysShoestaglogsByIds(ids));
    }
}
